package com.example.advice;

import com.example.Exception.BaseException;
import com.example.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class Controlleradvice {
    @ExceptionHandler(Exception.class )
    public Result Exceptione(Exception e) {
        log.error("统一异常,发生错误了=>,{}",e.getMessage());
        return Result.eorre(e.getMessage());
    }
    @ExceptionHandler(BaseException.class)
    public Result BaseException(BaseException e) {
        log.error("业务异常{}",e.getMessage());
        return  Result.eorre(e.getMessage());
    }
}
